<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="项目标题" prop="globalProjectTitle">
        <el-input
          v-model="queryParams.globalProjectTitle"
          placeholder="请输入全域项目标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="全域小标题" prop="globalSmallTitle">
        <el-input
          v-model="queryParams.globalSmallTitle"
          placeholder="请输入全域小标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总项目区面积" prop="totalProjectArea">
        <el-input
          v-model="queryParams.totalProjectArea"
          placeholder="请输入总项目区面积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="现有耕地面积" prop="existingCultivatedArea">
        <el-input
          v-model="queryParams.existingCultivatedArea"
          placeholder="请输入现有耕地面积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="新增耕地面积" prop="newlyIncreasedCultivatedArea">
        <el-input
          v-model="queryParams.newlyIncreasedCultivatedArea"
          placeholder="请输入新增耕地面积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="建设用地指标(增减挂)" prop="constructionLandIndex">
        <el-input
          v-model="queryParams.constructionLandIndex"
          placeholder="请输入建设用地指标(增减挂)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="提质改造耕地(旱改水)" prop="qualityImprovedCultivatedArea">
        <el-input
          v-model="queryParams.qualityImprovedCultivatedArea"
          placeholder="请输入提质改造耕地(旱改水)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产生占补平衡指标" prop="balanceIndex">
        <el-input
          v-model="queryParams.balanceIndex"
          placeholder="请输入产生占补平衡指标"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流转" prop="transferredLand">
        <el-input
          v-model="queryParams.transferredLand"
          placeholder="请输入流转"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="未来将建设农事服务中心" prop="futureServiceCenters">
        <el-input
          v-model="queryParams.futureServiceCenters"
          placeholder="请输入未来将建设农事服务中心"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="陆续流转" prop="futureTransferredLand">
        <el-input
          v-model="queryParams.futureTransferredLand"
          placeholder="请输入陆续流转"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生态矿旅标题" prop="ecoMiningTourTitle">
        <el-input
          v-model="queryParams.ecoMiningTourTitle"
          placeholder="请输入生态矿旅标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="景区title_A" prop="scenicTitleA">
        <el-input
          v-model="queryParams.scenicTitleA"
          placeholder="请输入景区title_A"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="景区title_B" prop="scenicTitleB">
        <el-input
          v-model="queryParams.scenicTitleB"
          placeholder="请输入景区title_B"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="农事服务标题" prop="agriculturalServiceTitle">
        <el-input
          v-model="queryParams.agriculturalServiceTitle"
          placeholder="请输入农事服务标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="农事服务小标题" prop="agriculturalServiceSmalltitle">
        <el-input
          v-model="queryParams.agriculturalServiceSmalltitle"
          placeholder="请输入农事服务小标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="small_title_A" prop="smallTitleA">
        <el-input
          v-model="queryParams.smallTitleA"
          placeholder="请输入small_title_A"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="small_title_B" prop="smallTitleB">
        <el-input
          v-model="queryParams.smallTitleB"
          placeholder="请输入small_title_B"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="small_title_C" prop="smallTitleC">
        <el-input
          v-model="queryParams.smallTitleC"
          placeholder="请输入small_title_C"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="small_title_D" prop="smallTitleD">
        <el-input
          v-model="queryParams.smallTitleD"
          placeholder="请输入small_title_D"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="small_title_E" prop="smallTitleE">
        <el-input
          v-model="queryParams.smallTitleE"
          placeholder="请输入small_title_E"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="small_title_F" prop="smallTitleF">
        <el-input
          v-model="queryParams.smallTitleF"
          placeholder="请输入small_title_F"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="small_title_G" prop="smallTitleG">
        <el-input
          v-model="queryParams.smallTitleG"
          placeholder="请输入small_title_G"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="small_title_H" prop="smallTitleH">
        <el-input
          v-model="queryParams.smallTitleH"
          placeholder="请输入small_title_H"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="数字乡村标题" prop="digitalCountrysideTitle">
        <el-input
          v-model="queryParams.digitalCountrysideTitle"
          placeholder="请输入数字乡村标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="数字乡村title_A" prop="digitalCountrysideTitleA">
        <el-input
          v-model="queryParams.digitalCountrysideTitleA"
          placeholder="请输入数字乡村title_A"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="数字乡村title_B" prop="digitalCountrysideTitleB">
        <el-input
          v-model="queryParams.digitalCountrysideTitleB"
          placeholder="请输入数字乡村title_B"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['dash:farmland:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['dash:farmland:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['dash:farmland:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['dash:farmland:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="farmlandList" @selection-change="handleSelectionChange">
      
      <el-table-column min-width="120" type="selection" width="55" align="center" />
      <el-table-column min-width="120" label="全域项目标题" align="center" prop="globalProjectTitle" show-overflow-tooltip/>
      <el-table-column min-width="120" label="全域小标题" align="center" prop="globalSmallTitle" show-overflow-tooltip/>
      <el-table-column min-width="120" label="项目简介" align="center" prop="introduction" show-overflow-tooltip/>
      <el-table-column min-width="120" label="总项目区面积" align="center" prop="totalProjectArea" />
      <el-table-column min-width="120" label="现有耕地面积" align="center" prop="existingCultivatedArea" />
      <el-table-column min-width="120" label="新增耕地面积" align="center" prop="newlyIncreasedCultivatedArea" />
      <el-table-column min-width="120" label="建设用地指标(增减挂)" align="center" prop="constructionLandIndex" />
      <el-table-column min-width="120" label="提质改造耕地(旱改水)" align="center" prop="qualityImprovedCultivatedArea" />
      <el-table-column min-width="120" label="产生占补平衡指标" align="center" prop="balanceIndex" />
      <el-table-column min-width="120" label="流转" align="center" prop="transferredLand" />
      <el-table-column min-width="120" label="未来将建设农事服务中心（个）" align="center" prop="futureServiceCenters" />
      <el-table-column min-width="120" label="陆续流转" align="center" prop="futureTransferredLand" />
      <el-table-column min-width="120" label="生态矿旅标题" align="center" prop="ecoMiningTourTitle" show-overflow-tooltip/>
      <el-table-column min-width="120" label="景区标题_A" align="center" prop="scenicTitleA" />
      <el-table-column min-width="120" label="景区标题_A图片" align="center" prop="scenicTitleAImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.scenicTitleAImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column min-width="120" label="景区标题_B" align="center" prop="scenicTitleB" show-overflow-tooltip/>
      <el-table-column min-width="120" label="景区_B" align="center" prop="scenicTitleBImg" width="100" show-overflow-tooltip>
        <template slot-scope="scope">
          <image-preview :src="scope.row.scenicTitleBImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column min-width="120" label="农事服务标题" align="center" prop="agriculturalServiceTitle"  show-overflow-tooltip/>
      <el-table-column min-width="120" label="农事简介" align="center" prop="agriculturalIntroduction" show-overflow-tooltip/>
      <el-table-column min-width="120" label="农事服务小标题" align="center" prop="agriculturalServiceSmalltitle" />
      <el-table-column min-width="120" label="模式_A" align="center" prop="smallTitleA" show-overflow-tooltip/>
      <el-table-column min-width="120" label="模式_B" align="center" prop="smallTitleB" show-overflow-tooltip/>
      <el-table-column min-width="120" label="模式_C" align="center" prop="smallTitleC" show-overflow-tooltip/>
      <el-table-column min-width="120" label="模式_D" align="center" prop="smallTitleD" show-overflow-tooltip/>
      <el-table-column min-width="120" label="模式_E" align="center" prop="smallTitleE" show-overflow-tooltip/>
      <el-table-column min-width="120" label="模式_F" align="center" prop="smallTitleF" show-overflow-tooltip/>
      <el-table-column min-width="120" label="模式_G" align="center" prop="smallTitleG" show-overflow-tooltip/>
      <el-table-column min-width="120" label="模式_H" align="center" prop="smallTitleH" show-overflow-tooltip/>
      <el-table-column min-width="120" label="数字乡村标题" align="center" prop="digitalCountrysideTitle" show-overflow-tooltip/>
      <el-table-column min-width="120" label="数字乡村标题_A" align="center" prop="digitalCountrysideTitleA" show-overflow-tooltip/>
      <el-table-column min-width="120" label="数字乡村标题_A图片" align="center" prop="digitalCountrysideTitleAImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.digitalCountrysideTitleAImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column min-width="120" label="数字乡村标题_B" align="center" prop="digitalCountrysideTitleB" />
      <el-table-column min-width="120" label="数字乡村标题_B图片" align="center" prop="digitalCountrysideTitleBImg" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.digitalCountrysideTitleBImg" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column min-width="120" label="宣传视频" align="center" prop="farmlandPromotionVideoUrl" show-overflow-tooltip>
        <template slot-scope="scope">
          <!-- 显示"查看视频"按钮 -->
          <el-button
            v-if="scope.row.farmlandPromotionVideoUrl"
            type="text"
            icon="el-icon-video-camera"
            @click="openVideo(scope.row.farmlandPromotionVideoUrl)"
          >
            查看视频
          </el-button>
          <!-- 没有视频时显示 -->
          <span v-else>无</span>
        </template>

      </el-table-column> 
      <el-table-column min-width="120" label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
           v-hasPermi="['dash:farmland:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['dash:farmland:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改高标准农田对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body>
  <el-form ref="form" :model="form" :rules="rules" label-width="150px">
    <!-- 第一行：4个基础信息项 -->
    <el-divider content-position="left" style="color: #666; font-size: 14px;">全域项目</el-divider>
    <el-row :gutter="20"> <!-- gutter=20 控制列间距，单位px -->
      <el-col :span="6"> <!-- 每列占6份，4列共24份 -->
        <el-form-item label="域项目标题" prop="globalProjectTitle">
          <el-input v-model="form.globalProjectTitle" placeholder="请输入全域项目标题"  width="100px"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="全域小标题" prop="globalSmallTitle">
          <el-input v-model="form.globalSmallTitle" placeholder="请输入全域小标题" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="总项目区面积" prop="totalProjectArea">
          <el-input v-model="form.totalProjectArea" placeholder="请输入总项目区面积" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="现有耕地面积" prop="existingCultivatedArea">
          <el-input v-model="form.existingCultivatedArea" placeholder="请输入现有耕地面积" />
        </el-form-item>
      </el-col>
    </el-row>

    <!-- 第二行：4个面积指标项 -->
    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="新增耕地面积" prop="newlyIncreasedCultivatedArea">
          <el-input v-model="form.newlyIncreasedCultivatedArea" placeholder="请输入新增耕地面积" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="建设用地指标(增减挂)" prop="constructionLandIndex">
          <el-input v-model="form.constructionLandIndex" placeholder="请输入建设用地指标(增减挂)" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="提质改造耕地(旱改水)" prop="qualityImprovedCultivatedArea">
          <el-input v-model="form.qualityImprovedCultivatedArea" placeholder="请输入提质改造耕地(旱改水)" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="产生占补平衡指标" prop="balanceIndex">
          <el-input v-model="form.balanceIndex" placeholder="请输入产生占补平衡指标" />
        </el-form-item>
      </el-col>
    </el-row>

    <!-- 第三行：4个流转与服务项 -->
    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="流转" prop="transferredLand">
          <el-input v-model="form.transferredLand" placeholder="请输入流转" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="将建设农事服务中心" prop="futureServiceCenters">
          <el-input v-model="form.futureServiceCenters" placeholder="请输入未来将建设农事服务中心个数" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="陆续流转" prop="futureTransferredLand">
          <el-input v-model="form.futureTransferredLand" placeholder="请输入陆续流转" />
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="项目简介" prop="introduction">
          <el-input v-model="form.introduction" type="textarea" placeholder="请输入内容" rows="4" />
        </el-form-item>
      </el-col>
    </el-row>

    <el-divider content-position="left" style="color: #666; font-size: 14px;">生产矿旅</el-divider>

    <!-- 第四行：4个景区相关项 -->
    <el-row :gutter="18">
      <el-col :span="4">
        <el-form-item label="生态矿旅标题" prop="ecoMiningTourTitle">
          <el-input v-model="form.ecoMiningTourTitle" placeholder="请输入生态矿旅标题" />
        </el-form-item>
      </el-col>
      <el-col :span="4">
        <el-form-item label="景区A" prop="scenicTitleA">
          <el-input v-model="form.scenicTitleA" placeholder="请输入景区title_A" />
        </el-form-item>
      </el-col>
      <el-col :span="4">
        <el-form-item label="景区A图片" prop="scenicTitleAImg">
          <image-upload v-model="form.scenicTitleAImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="4">
        <el-form-item label="景区B" prop="scenicTitleB">
          <el-input v-model="form.scenicTitleB" placeholder="请输入景区名称_B" />
        </el-form-item>
      </el-col>
      <el-col :span="4">
        <el-form-item label="景区B图片" prop="scenicTitleBImg">
          <image-upload v-model="form.scenicTitleBImg"/>
        </el-form-item>
      </el-col>
    </el-row>

    <el-divider content-position="left" style="color: #666; font-size: 14px;">农事服务</el-divider>
    <!-- 第五行：4个农事服务项 -->
    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="农事服务标题" prop="agriculturalServiceTitle">
          <el-input v-model="form.agriculturalServiceTitle" placeholder="请输入农事服务标题" />
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="农事简介" prop="agriculturalIntroduction">
          <el-input v-model="form.agriculturalIntroduction" type="textarea" placeholder="请输入内容" rows="4" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="农事服务模式标题" prop="agriculturalServiceSmalltitle">
          <el-input v-model="form.agriculturalServiceSmalltitle" placeholder="请输入农事服务小标题" />
        </el-form-item>
      </el-col>
    </el-row>

    <!-- 第六行：4个smallTitle项 -->
    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="模式A" prop="smallTitleA">
          <el-input v-model="form.smallTitleA" placeholder="请输入模式1" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="模式B" prop="smallTitleB">
          <el-input v-model="form.smallTitleB" placeholder="请输入模式2" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="模式C" prop="smallTitleC">
          <el-input v-model="form.smallTitleC" placeholder="请输入模式3" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="模式D" prop="smallTitleD">
          <el-input v-model="form.smallTitleD" placeholder="请输入模式4" />
        </el-form-item>
      </el-col>
      
    </el-row>

    <!-- 第七行：4个数字乡村相关项 -->
    <el-row :gutter="20">
      <el-col :span="6">
        <el-form-item label="模式E" prop="smallTitleE">
          <el-input v-model="form.smallTitleE" placeholder="请输入模式5" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="模式F" prop="smallTitleF">
          <el-input v-model="form.smallTitleF" placeholder="请输入模式6" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="模式G" prop="smallTitleG">
          <el-input v-model="form.smallTitleG" placeholder="请输入模式7" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="模式H" prop="smallTitleH">
          <el-input v-model="form.smallTitleH" placeholder="请输入模式8" />
        </el-form-item>
      </el-col>
    </el-row>

    <el-divider content-position="left" style="color: #666; font-size: 14px;">数字乡村</el-divider>


    <!-- 第八行： -->
     <el-row :gutter="20">
      <el-col :span="4">
        <el-form-item label="数字乡村标题" prop="digitalCountrysideTitle">
          <el-input v-model="form.digitalCountrysideTitle" placeholder="请输入数字乡村标题" />
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      
      <el-col :span="6">
        <el-form-item label="数字乡村标题_A" prop="digitalCountrysideTitleA">
          <el-input v-model="form.digitalCountrysideTitleA" placeholder="请输入数字乡村title_A" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="数字乡村标题_A图片" prop="digitalCountrysideTitleAImg">
          <image-upload v-model="form.digitalCountrysideTitleAImg"/>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="数字乡村标题_B" prop="digitalCountrysideTitleB">
          <el-input v-model="form.digitalCountrysideTitleB" placeholder="请输入数字乡村标题_B" />
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="数字乡村标题_B图片" prop="digitalCountrysideTitleBImg">
          <image-upload v-model="form.digitalCountrysideTitleBImg"/>
        </el-form-item>
      </el-col>
     
    </el-row>
    <el-row>
      <el-col :span="8">
        <el-form-item label="高标准农田宣传视频" prop="farmlandPromotionVideoUrl">
          <video-upload v-model="form.farmlandPromotionVideoUrl" placeholder="请输入高标准农田宣传视频URL" />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>

  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="submitForm">确 定</el-button>
    <el-button @click="cancel">取 消</el-button>
  </div>
</el-dialog>
<video-column ref="videoPlayer"></video-column>
  </div>
</template>

<script>
import { listFarmland, getFarmland, delFarmland, addFarmland, updateFarmland } from "@/api/dash/farmland"

export default {
  name: "Farmland",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 高标准农田表格数据
      farmlandList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        globalProjectTitle: null,
        globalSmallTitle: null,
        introduction: null,
        totalProjectArea: null,
        existingCultivatedArea: null,
        newlyIncreasedCultivatedArea: null,
        constructionLandIndex: null,
        qualityImprovedCultivatedArea: null,
        balanceIndex: null,
        transferredLand: null,
        futureServiceCenters: null,
        futureTransferredLand: null,
        ecoMiningTourTitle: null,
        scenicTitleA: null,
        scenicTitleAImg: null,
        scenicTitleB: null,
        scenicTitleBImg: null,
        agriculturalServiceTitle: null,
        agriculturalIntroduction: null,
        agriculturalServiceSmalltitle: null,
        smallTitleA: null,
        smallTitleB: null,
        smallTitleC: null,
        smallTitleD: null,
        smallTitleE: null,
        smallTitleF: null,
        smallTitleG: null,
        smallTitleH: null,
        digitalCountrysideTitle: null,
        digitalCountrysideTitleA: null,
        digitalCountrysideTitleAImg: null,
        digitalCountrysideTitleB: null,
        digitalCountrysideTitleBImg: null,
        farmlandPromotionVideoUrl: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        globalProjectTitle: [
          { required: true, message: "全域项目标题不能为空", trigger: "blur" }
        ],
        ecoMiningTourTitle: [
          { required: true, message: "生态矿旅标题不能为空", trigger: "blur" }
        ],
        agriculturalServiceTitle: [
          { required: true, message: "农事服务标题不能为空", trigger: "blur" }
        ],
        digitalCountrysideTitle: [
          { required: true, message: "数字乡村标题不能为空", trigger: "blur" }
        ],
        updateTime: [
          { required: true, message: "修改时间不能为空", trigger: "blur" }
        ]
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
     openVideo(url) {
      this.$refs.videoPlayer.openVideo(url)
    },
    /** 查询高标准农田列表 */
    getList() {
      this.loading = true
      listFarmland(this.queryParams).then(response => {
        this.farmlandList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        globalProjectTitle: null,
        globalSmallTitle: null,
        introduction: null,
        totalProjectArea: null,
        existingCultivatedArea: null,
        newlyIncreasedCultivatedArea: null,
        constructionLandIndex: null,
        qualityImprovedCultivatedArea: null,
        balanceIndex: null,
        transferredLand: null,
        futureServiceCenters: null,
        futureTransferredLand: null,
        ecoMiningTourTitle: null,
        scenicTitleA: null,
        scenicTitleAImg: null,
        scenicTitleB: null,
        scenicTitleBImg: null,
        agriculturalServiceTitle: null,
        agriculturalIntroduction: null,
        agriculturalServiceSmalltitle: null,
        smallTitleA: null,
        smallTitleB: null,
        smallTitleC: null,
        smallTitleD: null,
        smallTitleE: null,
        smallTitleF: null,
        smallTitleG: null,
        smallTitleH: null,
        digitalCountrysideTitle: null,
        digitalCountrysideTitleA: null,
        digitalCountrysideTitleAImg: null,
        digitalCountrysideTitleB: null,
        digitalCountrysideTitleBImg: null,
        farmlandPromotionVideoUrl: null,
        updateTime: null
      }
      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = "添加高标准农田"
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      getFarmland(id).then(response => {
        this.form = response.data
        this.open = true
        this.title = "修改高标准农田"
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateFarmland(this.form).then(response => {
              this.$modal.msgSuccess("修改成功")
              this.open = false
              this.getList()
            })
          } else {
            addFarmland(this.form).then(response => {
              this.$modal.msgSuccess("新增成功")
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除高标准农田编号为"' + ids + '"的数据项？').then(function() {
        return delFarmland(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('dash/farmland/export', {
        ...this.queryParams
      }, `farmland_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
